﻿<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Models.Contacts>>" %>--%>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<int>" %>
<%@ Import Namespace="CRM.Models" %>
<%@ Import Namespace="CRM.Resourses" %>

<%
    var contactsCol = new CRM.Database.Model.ContactsCollection();
%>

<%var grid = Html.DevExpress().GridView(settings =>
    {
        settings.Name = "gdAuthorizationAddresses";
        settings.KeyFieldName = "IdContact";
        settings.SettingsPager.PageSize = 20;
        settings.CommandColumn.Visible = true;
        settings.CommandColumn.NewButton.Visible = false;
        settings.CommandColumn.DeleteButton.Visible = false;
        settings.CommandColumn.EditButton.Visible = true;
        settings.SettingsBehavior.ConfirmDelete = true;
        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
        settings.CallbackRouteValues = new { Controller = "TC", Action = "CustomerAuthorizationEditPartial", customerId = Model };
        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "TC", Action = "CustomerAuthorizationEditPartialEdit", customerId = Model };
        settings.SettingsEditing.ShowModelErrorsForEditors = true;
        settings.Columns.Add(column =>
                                {
                                    column.Caption = Resourses.customerLegalEntity;
                                    column.FieldName = "LegalEntities.Name";
                                    column.ReadOnly = true;
                                });
        settings.Columns.Add(column =>
                                {
                                    column.Caption = Resourses.Name;
                                    column.FieldName = "Name";
                                    column.ReadOnly = true;
                                });
        settings.Columns.Add(column =>
                                {
                                    column.Caption = Resourses.Phone;
                                    column.FieldName = "Phone";
                                    column.ReadOnly = true;
                                });
        settings.Columns.Add(column =>
                                {
                                    column.Caption = Resourses.Email;
                                    column.FieldName = "Email";
                                    column.ReadOnly = true;
                                });
        settings.Columns.Add(column =>
                                {
                                    column.Caption = Resourses.ContactLoginName;
                                    column.FieldName = "LoginName";
                                });
        settings.Columns.Add(column =>
                                {
                                    column.Caption = Resourses.Password;
                                    column.FieldName = "Pass";
                                });
    });
    if (ViewData["EditError"] != null){ grid.SetEditErrorText((string)ViewData["EditError"]); }
    grid.Bind(contactsCol.GetFullDefinedContactsByCustomerId(Model)).GetHtml();
    //grid.Bind(DB.GetFullDefinedContactsByCustomerId(Model)).GetHtml();
    %>